//
//  AccountSafeViewController.m
//  HTP
//
//  Created by 陈钱钿 on 15/11/3.
//  Copyright © 2015年 nit. All rights reserved.
//

#import "AccountSafeViewController.h"
#import "ChangePwdViewController.h"
#import <QuartzCore/QuartzCore.h>
#import "FeedbackViewModel.h"
#define kBorder 20
#define cellHeight 40
@interface AccountSafeViewController ()
@property (nonatomic, retain) UIView *first;
@property (nonatomic, retain) UIView *second;
@property (nonatomic, retain) UIView *thrid;
@property (nonatomic, retain) UIWindow *window;
@property (nonatomic, retain) UIView *alterView;
@end

@implementation AccountSafeViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    
    [self addCustomBackBase];
    [self initUI];
}

- (void)viewWillAppear:(BOOL)animated {
    
}
//绘制UI
- (void)initUI{
    self.view.backgroundColor = [UIColor colorWithRed:233.0/255 green:233.0/255 blue:233.0/255 alpha:1];
    [self addCustomTitleWithTitle:@"帐号与安全"];
    
    self.first = [[UIView alloc] initWithFrame:CGRectMake(0, kBorder, ScreenWidth, cellHeight)];
    self.first.backgroundColor = [UIColor whiteColor];
    UILabel *nameLabel = [[UILabel alloc] initWithFrame:CGRectMake(kBorder, 0, 120, cellHeight)];
    nameLabel.text = @"姓名";
    [self.first addSubview:nameLabel];
    UILabel *name = [[UILabel alloc] initWithFrame:CGRectMake(ScreenWidth-120, 0, 100, cellHeight)];
    name.textColor = [UIColor grayColor];
    name.text = @"薛丽丽";
    name.textAlignment = NSTextAlignmentRight;
    [self.first addSubview:name];
    [self.view addSubview:self.first];
    
    self.second = [[UIView alloc] initWithFrame:CGRectMake(0, CGRectGetMaxY(self.first.frame)+kBorder, 320, cellHeight+1)];
    self.second.backgroundColor = [UIColor whiteColor];
    UILabel *phoneLabel = [[UILabel alloc] initWithFrame:CGRectMake(kBorder, 0, 120, cellHeight)];
    phoneLabel.text = @"手机号";
    [self.second addSubview:phoneLabel];
    UILabel *phone = [[UILabel alloc] initWithFrame:CGRectMake(ScreenWidth-140, 0, 120, cellHeight)];
    phone.textAlignment = NSTextAlignmentRight;
    phone.text = @"18368493635";
    [self.second addSubview:phone];
    UIImageView *line = [[UIImageView alloc] initWithFrame:CGRectMake(kBorder, CGRectGetMaxY(phoneLabel.frame), ScreenWidth-2*kBorder, 1)];
    line.image = [UIImage imageNamed:@"settingline"];
    [self.second addSubview:line];
    [self.view addSubview:self.second];
    
    self.thrid = [[UIView alloc] initWithFrame:CGRectMake(0, CGRectGetMaxY(self.second.frame), ScreenWidth, cellHeight)];
    self.thrid.backgroundColor = [UIColor whiteColor];
    UILabel *pwdLabel = [[UILabel alloc] initWithFrame:CGRectMake(kBorder, 0, 120, cellHeight)];
    pwdLabel.text = @"登录密码";
    [self.thrid addSubview:pwdLabel];
    UIButton *pwdMore = [[UIButton alloc] initWithFrame:CGRectMake(ScreenWidth-30, 9.5, 13, 25)];
    [pwdMore setBackgroundImage:[UIImage imageNamed:@"more"] forState:UIControlStateNormal];
    UITapGestureRecognizer *pwdGesture = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(pwdForward)];
    [self.thrid addGestureRecognizer:pwdGesture];
    [self.thrid addSubview:pwdMore];
    [self.view addSubview:self.thrid];
    

}

//点击登录密码 弹框
- (void)pwdForward {
    
    self.alterView = [[UIView alloc] initWithFrame:CGRectMake(kBorder, 44+CGRectGetMaxY(self.first.frame)+2*kBorder+cellHeight-5, ScreenWidth-2*kBorder, 44*2+20)];
    self.alterView.layer.cornerRadius = 7;
    self.alterView.backgroundColor = [UIColor colorWithRed:233.0/255 green:233.0/255 blue:233.0/255 alpha:1];
    
    UITextField *Field = [[UITextField alloc] initWithFrame:CGRectMake(kBorder, kBorder, ScreenWidth-4*kBorder, 31)];
    Field.placeholder = @"  输入原密码";
    Field.secureTextEntry = YES;
    Field.borderStyle = UITextBorderStyleRoundedRect;
    [self.alterView addSubview:Field];
    
    UIImageView *line = [[UIImageView alloc] initWithFrame:CGRectMake(kBorder, CGRectGetMaxY(Field.frame)+kBorder, ScreenWidth-4*kBorder, 1)];
    line.image = [UIImage imageNamed:@"settingline"];
    [self.alterView addSubview:line];
    
    UIButton *confirmBtn = [[UIButton alloc] initWithFrame:CGRectMake(0, CGRectGetMaxY(line.frame), ScreenWidth-2*kBorder, 37)];
    [confirmBtn setTitle:@"确认" forState:UIControlStateNormal];
    [confirmBtn setTitleColor:[UIColor orangeColor] forState:UIControlStateNormal];
    [confirmBtn addTarget:self action:@selector(confirmClick) forControlEvents:UIControlEventTouchUpInside];
    [self.alterView addSubview:confirmBtn];

    
    self.window = [[UIApplication sharedApplication] delegate].window ;
    [self.window addSubview:self.alterView];
    self.view.backgroundColor = [UIColor colorWithRed:124.0/255 green:124.0/255 blue:124.0/255 alpha:1];
    self.first.backgroundColor = [UIColor colorWithRed:135.0/255 green:135.0/255 blue:135.0/255 alpha:1];
    self.second.backgroundColor = [UIColor colorWithRed:135.0/255 green:135.0/255 blue:135.0/255 alpha:1];
    self.thrid.backgroundColor = [UIColor colorWithRed:135.0/255 green:135.0/255 blue:135.0/255 alpha:1];
}

//点击弹框中的确认按钮
- (void)confirmClick {
    [self.alterView removeFromSuperview];
    self.view.backgroundColor = [UIColor colorWithRed:233.0/255 green:233.0/255 blue:233.0/255 alpha:1];
    self.first.backgroundColor = [UIColor whiteColor];
    self.second.backgroundColor = [UIColor whiteColor];
    self.thrid.backgroundColor = [UIColor whiteColor];
    
}


- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
